{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
                <input type="hidden" class="form-control " id="group_id" value= {{ head.group_id }}>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="btn-group">
                            {% if request.user.is_superuser %}
                                <a>
                                    <button id='bt-add' type="button" class="btn btn-primary">增加用户</button>
                                </a>
                                <a>
                                    <button id='bt-del' data-text="确定删除用户? 0个" type="button" class="btn btn-danger">
                                        删除用户
                                    </button>
                                </a>
                            {% endif %}
                            <a>
                                <button id='bt-search' type="button" class="btn btn-success">高级搜索</button>
                            </a>
                            <a>
                                <button id='bt-reset' type="button" class="btn btn-danger">重置高级搜索</button>
                            </a>
                            <div id="is_superuser_object" data-my-object="{{ is_superuser }}"></div>

                        </div>
                    </div>
                    <div class="panel-body">
                        <div id="div-search" class="hide">
                            <table id="high-search" style="width: 67%; margin: 0 auto 2em auto;" border="0"
                                   cellpadding="3" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>目标</th>
                                    <th>内容</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr id="_filter_username" data-column="2">
                                    <td>用户名</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_username" type="text"></td>
                                </tr>
                                <tr id="_filter_first_name" data-column="2">
                                    <td>用户拼音</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_first_name" type="text"></td>
                                </tr>
                                <tr id="_filter_email" data-column="2">
                                    <td>邮箱地址</td>
                                    <td align="center"><input style="width:100%" class="column_filter" id="filter_email"
                                                              type="text"></td>
                                </tr>
                                <tr id="_filter_project" data-column="5">
                                    <td>所在项目</td>
                                    <td align="center">
                                        <select id="filter_project" class="filter_select2" style="width: 100%">
                                            <option value="全部" selected="selected">全部</option>
                                            {% for project in all_project %}
                                                <option value={{ project.id }}>{{ project.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_project_group" data-column="2">
                                    <td>所在项目分组</td>
                                    <td align="center">
                                        <select id="filter_project_group" class="filter_select2" style="width: 100%">
                                            <option value="全部" selected="selected">全部</option>
                                            {% for project_group in all_project_group %}
                                                <option value={{ project_group.id }}>{{ project_group.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_group" data-column="5">
                                    <td>部门</td>
                                    <td align="center">
                                        <select id="filter_group" class="filter_select2" style="width: 100%">
                                            <option value="全部" selected="selected">全部</option>
                                            {% for group in all_group %}
                                                <option value={{ group.id }}>{{ group.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_is_superuser" data-column="5">
                                    <td>用户类型</td>
                                    <td align="center">
                                        <select id="filter_is_superuser" class="filter_select2" style="width: 100%">
                                            <option value="全部" selected="selected">全部</option>
                                            <option value="0">管理员</option>
                                            <option value="1">普通用户</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_is_active" data-column="5">
                                    <td>用户类型</td>
                                    <td align="center">
                                        <select id="filter_is_active" class="filter_select2" style="width: 100%">
                                            <option value="全部" selected="selected">全部</option>
                                            <option value="0">在职</option>
                                            <option value="1">离职</option>
                                        </select>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <table id="mytable" class="display" width="100%" cellspacing="0">
                            <thead>
                            <tr>
                                <th class="center sorting_disabled">
                                    <label class="pos-rel">
                                        <input id='chb-all' type="checkbox"/>
                                    </label>
                                </th>
                                <th>id</th>
                                <th>用户名</th>
                                <th>用户拼音</th>
                                <th>公司邮箱</th>
                                <!--<th>所在项目</th>-->
                                <th>部门</th>
                                <th>部门分组</th>
                                <th>分配到项目分组</th>
                                <th>用户类型</th>
                                <th>在职情况</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
            <!-- Modal -->
            <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"></h4>
                        </div>
                        <div class="modal-body">
                            <div class="alert alert-danger alert-dismissable" id='modal-notify'>
                                <button type="button" class="close" id="bt-modal-notify">&times;</button>
                                <label id='lb-msg'></label>
                            </div>
                            <form class="form-horizontal" role="form">
                                <div class="form-group" id="show_id">
                                    <label class="col-sm-3 control-label">id</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control " id="id">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">用户名</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control immutable" id="username">
                                    </div>
                                </div>
                                <div class="form-group" id='show_first_name'>
                                    <label class="col-sm-3 control-label">用户拼音</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control immutable" id="first_name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">公司邮箱</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control immutable" id="email">
                                    </div>
                                </div>
                                <div class="form-group" style="display: none">
                                    <label class="col-sm-3 control-label">所在项目</label>
                                    <div class="col-sm-8">
                                        <select id="add_game_project" class="immutable subordinate_user"
                                                style="width: 100%">
                                            <option selected="selected" value="0">选择项目</option>
                                        </select>
                                    </div>
                                    <button id="reset_project" type="button" class="btn btn-default btn-sm">x</button>
                                </div>
                                <div class="form-group" style="display: none">
                                    <label class="col-sm-3 control-label">项目分组</label>
                                    <div class="col-sm-8">
                                        <select id="project_group" class="immutable subordinate_user"
                                                style="width: 100%">
                                            <option selected="selected" value="0">选择项目分组</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">部门</label>
                                    <div class="col-sm-8">
                                        <select id="add_group" class="immutable" style="width: 100%">
                                            <option selected="selected" value="0">选择部门</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">部门分组</label>
                                    <div class="col-sm-8">
                                        <select id="group_section" class="immutable" style="width: 100%">
                                            <option selected="selected" value="0">选择部门分组</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">用户类型</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline">
                                            <input type="radio" class="immutable" name="is_superuser" checked="checked"
                                                   value="0"/> 普通用户
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" class="immutable" name="is_superuser" value="1"/> 管理员
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">是否在职</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline">
                                            <input type="radio" class="immutable" name="is_active" checked="checked"
                                                   value="1"/> 是
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" class="immutable" name="is_active" value="0"/> 否
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group" id="show_ldap_group">
                                    <label class="col-sm-3 control-label">LDAP部门</label>
                                    <div class="col-sm-8">
                                        <select id="ldap_group" style="width: 100%">
                                            <option selected="selected" value="0">选择LDAP部门(不选则不添加LDAP账号)</option>
                                        </select>
                                    </div>
                                    <button type='button' id="reset_ldap_group">X</button>
                                </div>

                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button id='bt-save' type="button" class="btn btn-primary">保存</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->
            <div class="modal fade" id="Modal-passwd" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel-passwd">修改密码</h4>
                        </div>
                        <div class="modal-body">
                            <div class="alert alert-danger alert-dismissable" id='modal-passwd-notify2'>
                                <button type="button" class="close" id="bt-modal-passwd-notify">&times;</button>
                                <label id='lb-msg-passwd'></label>
                            </div>
                            <form class="form-horizontal" role="form">
                                <div class="form-group" id="show_passwd_id">
                                    <label class="col-sm-3 control-label">id</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control " id="id-passwd">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">新密码</label>
                                    <div class="col-sm-8">
                                        <!--<input type="text" class="form-control " id="password" type="password">-->
                                        <input class="form-control" placeholder="Password" id="password" type="password"
                                               value="">
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button id='bt-passwd-save' type="button" class="btn btn-primary">保存</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->
        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/jquery.dataTables.js"></script>
    {{ django_context_varable }}
    {% verbatim %}
    <script id="tpl" type="text/x-handlebars-template">
        {{#each func}}
        <button type="button" class="btn btn-{{this.type}} btn-sm" onclick="{{this.fn}}">{{this.name}}</button>
        {{/each}}
    </script>
    {% endverbatim %}
    <script src="/static/js/handlebars-v3.0.1.js"></script>
    <script src="/static/js/user_list.js?v=de42ce0ed53306fa9dec30f62594c5867600cdbe"></script>
    <script src="/static/js/jquery.toast.min.js"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
    <link href="/static/css/mycss.css" rel="stylesheet" type="text/css">
    <link href="/static/css/jquery.toast.min.css" rel="stylesheet" type="text/css">
{% endblock %}
